#include <string>
using namespace std;
/*
 * @lc app=leetcode.cn id=28 lang=cpp
 *
 * [28] 实现 strStr()
 */

// @lc code=start
class Solution {
public:
    // hecedello el
    int strStr(string haystack, string needle) {
        if (needle.size() == 0) return 0;
        for (int i = 0; i < haystack.size(); i++) {
            bool flag = true; int j = 0;
            // aaa aaaa
            for (; j + i < haystack.size() && j < needle.size(); j++) {
                if (haystack[j + i] != needle[j]) {
                    flag = false; break;
                }
            }
            if (flag && j == needle.size()) return i;
        }
        return -1;
    }
};
// @lc code=end

